package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.Material;
import com.ruoyi.system.domain.ProjectMaterial;
import com.ruoyi.system.mapper.MaterialMapper;
import com.ruoyi.system.mapper.ProjectMaterialMapper;
import com.ruoyi.system.service.IMaterialService;
import com.ruoyi.system.service.IProjectMaterialService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;


/**
 * 材料Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-03-11
 */
@Service
@RequiredArgsConstructor
public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material>  implements IMaterialService {

    private final MaterialMapper materialMapper;

    @Override
    public boolean saveMaterial(Material material) {
        QueryWrapper<Material> wrapper = new QueryWrapper<>();
        wrapper.eq("name",material.getName());
        wrapper.eq("unit",material.getUnit());
        wrapper.eq("specification",material.getSpecification());
        Material model = getOne(wrapper, false);
        if (model == null){
            save(material);
            return true;
        }
        return false;
    }
}
